﻿<%@ page language="C#" autoeventwireup="true" CodeFile="InformationCurrentStation.aspx.cs" inherits="Topo_InformationCurrentStation" enableEventValidation="false" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>信息利用率TOP20</title>
    <link href="../App_Themes/CSS/default.css" rel="stylesheet" type="text/css" />
    <link href="../JS/ext-3.0.0/resources/css/ext-all.css" rel="stylesheet" type="text/css" />

    <script src="../JS/Common/commonFun.js" type="text/javascript"></script>

    <script src="../JS/ext-3.0.0/adapter/ext/ext-base.js" type="text/javascript"></script>

    <script src="../JS/ext-3.0.0/ext-all.js" type="text/javascript"></script>

    <style type="text/css">
        .col_back_Yellow
        {
            background-color: Yellow;
        }
        .col_back_Green
        {
            background-color: #68DA69;
        }
        .col_back_Gray
        {
            background-color: #FFFFFF;
        }
        .col_back_Red
        {
            background-color: #D715F9;
        }
       /* .x-grid3-cell-inner
        {
            border-right: 1px solid black;
        }
        .x-grid3-row td, .x-grid3-summary-row td
        {
            padding-right: 0px;
        }
        .x-grid3-row
        {
            border-top-width: 0px;
            border-bottom-width: 0px;
        }
        .x-grid3-row
        {
            border: 1px solid black;
        }*/
        .x-grid3-header-offset
        {
            width: auto;
        }
        .ext-ie .x-grid3 table.ux-grid-group-table, .ext-safari .x-grid3 table.ux-grid-group-table
        {
            table-layout: auto;
        }
        .ux-grid-hd-group-cell
        {
            background: url(../extjs/resources/images/default/grid/grid3-hrow.gif) repeat-x bottom;
        }
    </style>

    <script type="text/javascript">
        Ext.onReady(function() {
            Ext.BLANK_IMAGE_URL = '../JS/ext-3.0.0/resources/images/default/s.gif';
            Ext.QuickTips.init(); //  浮动信息提示
            Ext.state.Manager.setProvider(new Ext.state.CookieProvider());
            var neid = getValueOfURLParamter('neid');
            var header = '10:00:21';
            var myData = Topo_InformationCurrentStation.GetModelList(neid).value;
            if (myData) {
                header = myData[0].TIMESTAMP.split(' ')[1];
            }
            function setColor(val, e) {
                var css = 'col_back';
                switch (val) {
                    case 'TCH':
                        e.css = css + '_Yellow';
                        break;
                    case 'IDLE':
                        e.css = css + '_Green';
                        break;
                    case 'NA':
                        e.css = css + '_Gray';
                        break;
                    case 'MCCH':
                        e.css = css + '_Red';
                        break;
                }
                return val;
            }
            function mergeData(val, e, store) {
                setColor(val, e);
                var v =store.data['DXT_' + grid.getColumnModel().getColumnHeader(e.id)];
                setColor(v, e);
                return '<div style="cursor :pointer;" onclick="openTBSChannelDetail(' + store.json.NEID + ')">' + val + '&nbsp;&nbsp;' + v + '</div>';
            }
            var reader = new Ext.data.ArrayReader({}, new Ext.data.Record.create([
                        { name: "NEID", mapping: "NEID", type: "string" },
                        { name: "UNIT", mapping: "UNIT", type: "string" },
                        { name: "TSL0", mapping: "TSL0", type: "string" },
                        { name: "TSL1", mapping: "TSL1", type: "string" },
                        { name: "TSL2", mapping: "TSL2", type: "string" },
                        { name: "TSL3", mapping: "TSL3", type: "string" },
                        { name: "DXT_TSL0", mapping: "DXTTSL0", type: "string" },
                        { name: "DXT_TSL1", mapping: "DXTTSL1", type: "string" },
                        { name: "DXT_TSL2", mapping: "DXTTSL2", type: "string" },
                        { name: "DXT_TSL3", mapping: "DXTTSL3", type: "string" },
                        { name: "EQUIPNAME", mapping: "EQUIPNAME", type: "string" },
                        { name: "TIMESTAMP", mapping: "TIMESTAMP", type: "string" },
                        { name: "BELONGDXT", mapping: "BELONGDXT", type: "string" }
                    ]));
            var gridData = new Ext.data.Store({
                proxy: new Ext.data.MemoryProxy(myData),
                reader: reader
            });
            gridData.load();
            var cm = new Ext.grid.ColumnModel({ defaults: { width: 60, sortable: true, menuDisabled: true }, columns: [
                       { id: 'UNIT', header: header, dataIndex: 'UNIT' },
                       { header: 'TSL0', renderer: mergeData, dataIndex: 'TSL0' },
                // { header: "DXT_TSL0", width: 56, sortable: true, dataIndex: 'DXT_TSL0', hidden: true },
                       {header: 'TSL1', renderer: mergeData, dataIndex: 'TSL1' },
                // { header: "DXT_TSL1", width: 56, sortable: true, dataIndex: 'DXT_TSL1', hidden: true },
                       {header: 'TSL2', renderer: mergeData, dataIndex: 'TSL2' },
                //{ header: "DXT_TSL2", width: 56, sortable: true, dataIndex: 'DXT_TSL2', hidden: true },
                       {header: 'TSL3', renderer: mergeData, dataIndex: 'TSL3'}//,
                // { header: "DXT_TSL3", width: 56, sortable: true, dataIndex: 'DXT_TSL3', hidden: true }
            ]
            });

            var grid = new Ext.grid.GridPanel({
                renderTo: 'InformationCurrentStation',
                ds: gridData, //数据内容
                cm: cm, //表头
                id: 'grid',
                columnLines: true,
                stripeRows: true,
                height: 300,
                width: 300,
                loadMask: new Ext.LoadMask(Ext.getDom('InformationCurrentStation'), { msg: "正在加载数据，请稍后..." })// 加载数据时遮蔽表格
            });

            function reLoadGrid() {
                try {
                    myData = Topo_InformationCurrentStation.GetModelList(neid).value;
                    if (myData) {
                        header = myData[0].TIMESTAMP.split(' ')[1];
                    }
                    // gridData.reload();
                    cm.config[0].header = header;
                    grid.reconfigure(gridData, cm);
                    //gridData.reload();
                    grid.getStore().loadData(myData);
                    // alert('加载成功');
                } catch (e) {
                    // alert('加载失败');
                }
            }
            
            setInterval(reLoadGrid, 5000); //界面5秒钟更新一次数据
        });
        function openTBSChannelDetail(neid) {
            var url = 'ChannelDetail.aspx?neid=' + neid;
            window.open(url, 'tbsChannelDetail', 'directorys=no,toolbar=no,status=no,menubar=no,scrollbars=no,resizable=no,width=950,height=620,left=20,top=10');
        }
    </script>

</head>
<body>
    <form id="form1" runat="server">
    <div id="InformationCurrentStation">
    </div>
    </form>
</body>
</html>
